﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WayneGameSolution.Chat
{
    public class PublicChatChannel : ChatChannelBase
    {
        public PublicChatChannel()
            : base()
        { }

        public PublicChatChannel(string id, string name, int timeoutSecond, ChannelType type)
            : base(id, name, timeoutSecond, type)
        { }

        public override IEnumerable<IChatMessage> GetUserMessage(string user)
        {
            DateTime  lt;

            LastReceivedTime.TryGetValue(user, out lt);
            if (lt == null) lt = DateTime.MinValue;

                var ls = SearchMessagesFromLast (lt  )
                    .Reverse ()  
                    .ToList();
                LastReceivedTime[user] = ls[ls.Count - 1].TimeStamp;
                return ls ;
     
          
        }
    }
}
